/*
 * @Description:
 * @Autor: Bingo
 * @Date: 2024-07-10 16:17:40
 * @LastEditors: Bingo
 * @LastEditTime: 2024-07-11 11:21:56
 */
import { showToast } from "vant";
export default {
  beforeMount(el: any, binding: any, vnode: any) {
    el._copyTextHandler = async (e: any) => {
      e.stopPropagation();
      try {
        await navigator.clipboard.writeText(binding.value);
        showToast("复制成功");
      } catch (err) {
        showToast("复制失败");
      }
    };

    el.addEventListener("click", el._copyTextHandler);
  },

  unmounted(el: any) {
    el.removeEventListener("click", el._copyTextHandler);
  },
};
